<template>
  <div class="opinion-item" :id="item.opinionId">
    <div class="col-layout" v-app-jump="{ to: `mtjimu://topic?id=${id}` }">
      <div class="opinion-user">
        <div class="flex-align-center" v-if="item.user">
          <img class="avatar" :src="item.user.avatar" />
          <div>
            <p class="nickname">{{ item.user.nickname }}</p>
            <p class="time">{{ item.onlineAt }}</p>
          </div>
        </div>
        <button class="follow-btn flex-align-center" v-if="item.user.uuid">关注</button>
      </div>
      <hybrid-article
        v-if="item.content"
        :outter-info="{
          content: item.content,
        }"
        class="opinion-content"
      ></hybrid-article>
      <div v-if="item.attachment" class="attachment">
        <div v-for="(att, index) in item.images" :key="index" :class="`img has-${item.total}`">
          <img :src="att.url" />
          <div class="mornum flex-align-center" v-if="item.total > 3 && index === 2">
            +{{ item.total - 3 }}
          </div>
        </div>
      </div>
      <div class="gap-line"></div>
      <div class="opinion-comment" v-if="item.statis && item.statis.commentCnt">
        <p class="title">评论</p>
        <comment-list :list="item.commentList"></comment-list>
      </div>
      <div class="gap-line" v-if="item.statis && item.statis.commentCnt"></div>
      <div class="comment action">
        <div class="flex-align">
          <img src="../../assets/images/icon-share.png" />
          {{ item.statis.shareCnt }}
        </div>
        <div class="line"></div>
        <div class="flex-align">
          <img src="../../assets/images/icon-comment.png" />
          {{ item.statis.commentCnt }}
        </div>
        <div class="line"></div>
        <div class="flex-align">
          <img src="../../assets/images/icon-thumb.png" />
          {{ item.statis.likeCnt }}
        </div>
      </div>
    </div>
    <div class="gap-rect"></div>
  </div>
</template>

<script>
  import CommentList from 'comp/CommentList';
  export default {
    props: {
      item: {
        type: Object,
      },
      id: {
        type: String,
      },
    },
    components: {
      CommentList,
    },
    data() {
      return {};
    },
    mounted() {
      this.item.total = this.item.attachment.length;
      this.item.images = this.item.attachment.splice(0, 3);
    },
    methods: {},
  };
</script>

<style lang="less">
  .opinion-item {
    .opinion-user {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-top: 4rem;
      margin-bottom: 2.5rem;
      .avatar {
        width: 8rem;
        height: 8rem;
        border-radius: 50%;
        margin-right: 1.7rem;
      }
      .nickname {
        font-size: 3.3rem;
        font-weight: 800;
        color: #cccccc;
      }
      .time {
        font-size: 2.4rem;
        color: #888888;
      }
      button.follow {
        img {
          width: 2.6rem;
          height: 2.6rem;
          margin-right: 1.3rem;
        }
        width: 14.8rem;
        height: 6rem;
        background: #1b1b1b;
        border-radius: 3rem;
        font-size: 2.8rem;
        color: #ffc600;
      }
    }
    .opinion-content {
      font-size: 2.8rem;
      color: #cccccc;
      line-height: 4.6rem;
      .content {
        -webkit-line-clamp: 4;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
      }
      img {
        width: 67rem;
        border-radius: 0;
      }
      .content {
        color: #cccccc;
      }
      .copy-right {
        display: none;
      }
    }

    .attachment {
      margin: 3rem auto;
      display: flex;
      width: 67rem;
      overflow: hidden;

      div.img {
        position: relative;
        flex: 1;
        overflow: hidden;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 0;
        // img {
        //   width: 100%;
        // }
        &:nth-last-child(3) {
          width: 21.7rem;
          height: 21.7rem;
        }
        &:nth-last-child(3) + div {
          width: 21.7rem;
          height: 21.7rem;
          margin-right: 1rem;
          margin-left: 1rem;
          border-radius: 0;
        }
        &:nth-last-child(3) + div + div {
          width: 21.7rem;
          height: 21.7rem;
        }
      }

      .has-1 {
        img {
          height: auto;
          width: 100%;
        }
        &:first-child {
          width: 100%;
          height: auto;
          max-height: 37.6875rem;
        }
      }
      .has-2 {
        &:first-child {
          margin-right: 1rem;
          width: 21.7rem;
          height: 21.7rem;
        }
        &:last-child {
          width: 21.7rem;
          height: 21.7rem;
        }
      }

      .mornum {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(#000000, 0.5);
        font-size: 3.6rem;
        font-family: PingFang SC;
        font-weight: 800;
        color: #ffffff;
      }
    }
    .article {
      padding: 0;
      .content {
        font-size: 2.8rem;
        line-height: 4.6rem;
      }
    }
    .opinion-comment {
      .title {
        font-size: 2.4rem;
        margin-bottom: 1rem;
        color: #888888;
        line-height: 4rem;
      }
    }
  }
</style>
